<template>
    <div class="container">
        <div
            class="content"
            v-if="$slots.default"
            :style="{
                height: status ? 'auto' : `${lineHeight * showNum}px`,
                overflow: status ? 'auto' : 'hidden',
            }"
        >
            <slot></slot>
        </div>
        <div v-else class="text">暂无数据</div>
        <div class="line" v-if="$slots.default">
            <div class="square" :class="{ rotate: status }" @click="handleClick">
                <div class="cicle">
                    <span class="el-icon-arrow-down"></span>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    name: 'CollapseDown',
    props: {
        lineHeight: {
            type: Number,
            default: 24,
        },
        showNum: {
            type: Number,
            default: 7,
        },
    },
    data() {
        return {
            status: false, //关闭状态
        }
    },
    methods: {
        handleClick() {
            this.status = !this.status
        },
    },
}
</script>
<style lang="scss">
.container {
    margin: 16px 0;
    .text{
        font-size: 16px;
        font-weight: 400;
        text-align: center;
        color: #8896a7;
    }
    .line {
        border: 1px solid #d2d4d6;
        position: relative;
        margin-top: 16px;
    }
    .square {
        cursor: pointer;
        width: 152px;
        height: 32px;
        background-color: #ffffff;
        align-items: center;
        justify-content: center;
        display: flex;
        position: absolute;
        top: -16px;
        left: calc(50% - 76px);
        .cicle {
            width: 32px;
            height: 32px;
            border-radius: 16px;
            background-color: #dfebfb;
            display: flex;
            justify-content: center;
            align-items: center;
        }
    }
    .rotate {
        transform: rotate(180deg);
    }
}
</style>